package game.classes.gameField;

import game.classes.interfaces.Block;
import game.enums.BlockID;
import game.enums.MaterialID;

public class gameBlock implements Block{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	int x;
	int y;
	BlockID bID;
	MaterialID mID;
	Block[][] list;
	
	public gameBlock(int x,int y,BlockID bID,Block[][] list)
	{
		this.x=x;
		this.y=y;
		this.bID=bID;
		this.list=list;
	}
	
	public gameBlock(int x,int y,BlockID bID,MaterialID mID,Block[][] list)
	{
		this.x=x;
		this.y=y;
		this.mID=mID;
		this.bID=bID;
		this.list=list;
	}
	
	@Override
	public int getX() {
		// TODO Auto-generated method stub
		return x;
	}

	@Override
	public int getY() {
		// TODO Auto-generated method stub
		return y;
	}

	@Override
	public MaterialID getMaterial() {
		// TODO Auto-generated method stub
		return this.mID;
	}

	@Override
	public BlockID getBlockID() {
		// TODO Auto-generated method stub
		return this.bID;
	}
	
	@Override
	
	public Block getBlockAbove() {
		// TODO Auto-generated method stub
		if(this.y==0)
		{
			return null;
		}
		return list[this.x][this.y-1];
	}

	@Override
	public Block getBlockRight() {
		// TODO Auto-generated method stub
		if(this.x+1<list.length)
		{
			return null;
		}
		return list[this.x+1][this.y];
	}

	@Override
	public Block getBlockLeft() {
		// TODO Auto-generated method stub
		if(this.x==0)
		{
			return null;
		}	
		return list[this.x-1][this.y];
	}

	@Override
	public Block getBlockBelow() {
		// TODO Auto-generated method stub
		if(this.y+1<list[0].length)
		{
			return null;
		}
		return list[this.x][this.y+1];
	}

	@Override
	public boolean isSolid() {
		switch (bID) {
		case BLOCK:
		case WALL:
		case TREE:
		case SOLID_BUSH:
		case GRAVE: {
			return true;
		}
		default:
		}
		return false;
	}


}
